//package com.zmn.plat.admin.controller.category;
//
//import java.util.List;
//
//import javax.servlet.http.HttpServletRequest;
//
//import com.zmn.common.dto2.ResponseDTO;
//import org.apache.shiro.authz.annotation.RequiresPermissions;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import com.zmn.common.constant.GlobalConsts;
//import com.zmn.common.constant.StatusConsts;
//import com.zmn.common.dto.ResultDTO;
//import com.zmn.common.utils.string.StringUtil;
//import com.zmn.plat.manager.dictionary.ProductDict;
//import com.zmn.plat.common.exception.PlatException;
//import com.zmn.plat.model.entity.category.BaseCategory;
//
///**
// * @author duanzuocai
// * @version v1.0
// * @since 2018/10/20 9:15
// */
//@Controller
//@RequestMapping("/categ/")
//public class CategoryModifyController extends CategoryBaseController {
//
//    @RequiresPermissions("/categ/updateStatus.action")
//    @RequestMapping(value = "updateStatus")
//    @ResponseBody
//    public ResponseDTO updateStatus(HttpServletRequest request, @RequestParam(value = "ids", defaultValue = "") String ids,
//                                    @RequestParam(value = "status", defaultValue = "0") int status) {
//
//        if (StringUtil.isBlank(ids)) {
//            return ResponseDTO.fail("请选择要更改状态的分类！");
//        }
//
//        List<Integer> arrayIds = StringUtil.convertStrsToList(ids);
//
//        ResponseDTO result = checkCategoryStatus(arrayIds, ProductDict.ERP_PRODUCT_TYPE, status);
//        if (result.getStatus() != StatusConsts.STATUS_SUCCESS) {
//            return result;
//        }
//
//        baseCategoryService.updateStatusBatch(arrayIds, status, getMcStaffRealName());
//
//        return ResponseDTO.success(StatusConsts.STATUS_SUCCESS,GlobalConsts.SUCCESS_MSG);
//    }
//
//    // @RequiresPermissions("/categ/updateSort.action")
//    @RequestMapping(value = "updateSort")
//    @ResponseBody
//    public ResponseDTO updateSort(HttpServletRequest request, @RequestParam(value = "id", defaultValue = "0") Integer categId,
//        @RequestParam(value = "sort", defaultValue = "0") Integer sort) {
//
//        if (categId == 0) {
//            return ResponseDTO.fail("请选择要更改排序的分类！");
//        }
//        if (sort == 0) {
//            return ResponseDTO.fail("请设置分类排序值！");
//        }
//
//        baseCategoryService.updateSortKey(categId, sort, getMcStaffRealName());
//        return ResponseDTO.success(StatusConsts.STATUS_SUCCESS, GlobalConsts.SUCCESS_MSG);
//    }
//
//    @SuppressWarnings("Duplicates")
//    @RequiresPermissions("/categ/addEdit.action")
//    @RequestMapping(value = "addEdit")
//    @ResponseBody
//    public ResponseDTO addEdit(HttpServletRequest request, @RequestBody BaseCategory category) {
//        int categId = category.getCategId();
//
//        try {
//            if (categId == 0) {
//                baseCategoryBService.insert(category, getMcStaffRealName());
//            } else {
//                baseCategoryBService.updateByKey(category, getMcStaffRealName());
//            }
//
//            return ResponseDTO.success(Integer.toString(category.getCategId()), GlobalConsts.SUCCESS_MSG);
//        } catch (org.springframework.dao.DuplicateKeyException ex) {
//            logger.error("分类已经存在，不能重复添加！", ex);
//            return ResponseDTO.fail("分类已经存在，不能重复添加！");
//        } catch (PlatException e) {
//            logger.error("PlatException！", e);
//            return ResponseDTO.fail(e.getMessage());
//        } catch (Exception ex) {
//            logger.error("[zmn]新增/修改产品分类失败", ex);
//            return  ResponseDTO.fail( GlobalConsts.FAILD_MSG);
//        }
//    }
//}
